import axiosServer from "@/utils/request";


/**
 * Add new announcement
 * @param notice Name
 * @param content Content
 * @param type Type
 * @param topping Top
 * @param important Important
 * @returns {Promise<AxiosResponse<any>> | *} 
 */
export const addAannoun = (notice, content, type, topping, important) => {
    return axiosServer({
        method: "post",
        url: "/notice/add",
        data: { notice, content, type, topping, important }
    });
};
// Delete
export const deleteAannoun = (id) => {
    return axiosServer({
        method: "delete",
        url: "/notice/delete/" + id,
    });
}
/**
 * Get announcements
 * @param {string} type 1 normal, 2 rolling, 3 popup
 * @param {number} page Page number
 * @param {number} limit Limit per page
 */
export const getAnnouns = (type, page, limit) => {
    return axiosServer({
        method: "get",
        url: "/notice/queryPage",
        params: { type: type, page: page, limit: limit }
    });
}
// Query by type
export const getAnnounOfTyoe = (type) => {
    return axiosServer({
        method: "get",
        url: "/notice/loadByType/" + type,
    });
}
// Query by id
export const getAnnounOfId = (id) => {
    return axiosServer({
        method: "get",
        url: "/notice/loadById/" + id,
    });
}
/**
 * Load top announcements
 * @returns {*}
 */
export const loadByTopping = () => {
    return axiosServer({
        method: "get",
        url: "/notice/loadByTopping",
    });
}

/**
 * Update top status
 * @param id ID
 * @param topping Top status
 * @returns {*}
 */
export const updateTopping = (id, topping) => {
    return axiosServer({
        method: "post",
        url: "/notice/updateTopping",
        params: {
            id, topping
        }
    });
}

/**
 * Update importance status
 * @param id ID
 * @param important Importance status
 * @returns {*}
 */
export const updateImportant = (id, important) => {
    return axiosServer({
        method: "post",
        url: "/notice/updateImportant",
        params: {
            id, important
        }
    });
}